Repository navigation
server: let the authentication handler authenticate a connection itself - #7
Merged
Merged
Conversation
Stebalien
force-pushed
the
steb/tls-auth
branch
from
November 5, 2026 19:32
41e127b to
2df2331
Compare
thatliuser
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For mTLS auth, we need authenticate the connection itself without checking user provided creds. This PR adds the hook we need to so that.
Note
Medium Risk
Changes the server authentication handshake order and can bypass password checks when a handler opts in, which is security-sensitive though backward compatible for handlers that do not implement the new interface.
Overview
Adds an optional
ConnectionAuthenticatorextension toAuthenticationHandler, so implementations can accept a client from the connection itself (e.g. TLS client certificate) after the handshake response and TLS upgrade, before credential lookup and password verification.The handshake path in
readHandshakeResponsetype-asserts the handler and, whenAuthenticateConnectionreturns true, finishes reading connect attributes and returns success without runninghandleAuthMatch/compareAuthData.OnAuthSuccessand the OK packet behave as for normal auth. Returning false keeps the existing password flow unchanged.Connect-attribute parsing is extracted into
readConnectAttributesand used in both branches. A new integration test uses a handler that accepts any TLS client cert and otherwise requires passwordsecret.Reviewed by Cursor Bugbot for commit 2df2331. Bugbot is set up for automated code reviews on this repo. Configure here.